package com.jyw.web.controller.system;

import com.jyw.common.annotation.Log;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.system.domain.vo.SysAutoOrderConfigVo;
import com.jyw.system.service.ISysAutoOrderConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Created by ZhangCheng on 2023/08/16 (系统自动派单配置)
 */
@Api(tags = "系统自动派单配置")
@RestController
@RequestMapping("/system/autoOrderConfig")
public class SysAutoOrderConfigController {

    @Autowired
    private ISysAutoOrderConfigService sysAutoOrderConfigService;

    /**
     * 获取系统自动派单配置
     *
     * @return
     */
    @GetMapping("/getConfig")
    @ApiOperation("获取系统自动派单配置")
    public CommonResult<SysAutoOrderConfigVo> getConfig() {
        return CommonResult.success(sysAutoOrderConfigService.getDefaultConfig());
    }

    /**
     * 修改系统自动派单配置
     *
     * @param sysAutoOrderConfigVo
     * @return
     */
    @Log(title = "修改系统自动派单配置", businessType = BusinessType.UPDATE)
    @PutMapping("/updateConfig")
    @ApiOperation("修改系统自动派单配置")
    public CommonResult updateConfig(@RequestBody SysAutoOrderConfigVo sysAutoOrderConfigVo) {
        sysAutoOrderConfigService.updateConfig(sysAutoOrderConfigVo);
        return CommonResult.success();
    }

}
